import Vue from 'vue'
import Vuex from 'vuex'

import { reqGetDetailsData } from '@/api'

Vue.use(Vuex)

const state = {
    categoryView: [],
    skuInfo: [],
    spuSaleAttrList: []

}
const actions = {

    // 获取数据
    async getDetailsDate({ commit }, id) {
        const result = await reqGetDetailsData(id)
        if (result.code === 200) {
            commit('DetailsPage', result.data)
        } else {
            console.log(result.message);
        }
    },



}
const mutations = {

    // 保存数据
    DetailsPage(state, data) {
        console.log(data.skuInfo.skuImageList);
        state.categoryView = data.categoryView,
            state.skuInfo = data.skuInfo,
            state.spuSaleAttrList = data.spuSaleAttrList
    }

}
const getters = {
    skuImageList(state) {
        return state.skuInfo.skuImageList
    }
}


export default {
    namespaced: true,
    state,
    actions,
    mutations,
    getters
}














